import { request, authRequest } from '@/utils/request.js'


/**
 * 用户登陆接口
 */	
export async function login(options) {
	options.method = 'post'
	options.data = {
		code: await this.getCode(),
		userInfo: options.userInfo
	}
	return await request(options);
}


/**
 * 刷新或 token 
 */
export async function refreToken(token) {
	return await request({
		method: 'put',
		url: '/authorization/refresh/token',
		header: {
			Authorization: 'Bearer ' + token
		}
	});
}


/**
 * 获取 Code
 */
export async function getCode() {
	
	let [err, result] = await uni.login()
	return result.code
}


export async function getCurrentUser(options = {}) {
  return await authRequest({
	  url: options.url
  })
}